package com.heima.common.exception;

import com.heima.model.common.enums.AppHttpCodeEnum;

/**
 * @ClassName CustomException
 * @Description TODO
 * @Author AWei
 * @DATE 2021/4/10 17:02
 * @Version 1.0
 */
public class CustomException extends RuntimeException {

    private AppHttpCodeEnum appHttpCodeEnum;

    public CustomException(AppHttpCodeEnum appHttpCodeEnum) {
        this.appHttpCodeEnum = appHttpCodeEnum;
    }

    public CustomException(AppHttpCodeEnum appHttpCodeEnum, String msg) {
        appHttpCodeEnum.setErrorMessage(msg);
        this.appHttpCodeEnum = appHttpCodeEnum;
    }

    public AppHttpCodeEnum getAppHttpCodeEnum() {
        return appHttpCodeEnum;
    }

    public static void custom(AppHttpCodeEnum codeEnum) {
        throw new CustomException(codeEnum);
    }

    public static void custom(AppHttpCodeEnum codeEnum, String msg) {
        throw new CustomException(codeEnum, msg);
    }

}
